*===============================================================================*
*																				*
*		THIS DO FILE PRODUCES ONLINE APPENDIX TABLE A9							*
* 		IN LONDONO-VELEZ AND QUERUBIN											*
*		"THE IMPACT OF EMERGENCY CASH ASSISTANCE IN A PANDEMIC: EXPERIMENTAL 	* 
* 		EVIDENCE FROM COLOMBIA", REVIEW OF ECONOMICS AND STATISTICS				*
*																				*
*		LAST MODIFIED: 2021-02-02												*
*																				*
*===============================================================================*

	use 	"${datadir}/balance.dta", clear
	
	gen 	N = 1
	label 	var N "N"
	gen 	control = treated==0
	global 	controls "Complete Incomplete Rejected Unreachable dist_week fea_hog_DPS_data cm cod_urban urban MPM sisben4 sisben3 Female age_01apr2020 estadocivil_1 estadocivil_2 estadocivil_3 estadocivil_4 estadocivil_5 victim dem4 edu0 inc sector_1 sector_2 sector_3 sector_4 sector_5 sector_6 sector_7 sector_8 sector_9 sector_10 sector_11 sector_12 sector_13 sector_14"
	
	glo 	rows = 43
	matrix results = J($rows,5,.)
	matrix rown results = $controls
	
	local oo = 0
	foreach o in $controls{	
		local l`o' : variable label `o'
				if `"`l`o''"' == "" {
					local l`o' "`o'"
					}
		local tt = 0
		foreach t of numlist 1 2{		
		qui: sum `o' if transfer2_type == `t' & treated==1
		matrix results[1+`oo',`tt'+1]=round(r(mean), .001)
		local tt = `tt'+1
		}
	qui: reg `o' transfer2_type_2 if treated==1, r
	matrix results[1+`oo',3]=round((2 * ttail(e(df_r), abs(_b[transfer2_type_2]/_se[transfer2_type_2]))), .001)	
	qui: reghdfe `o' transfer2_type_2 if treated==1, abs(codmunicipio) vce(robust)	
	matrix results[1+`oo',4]=round((2 * ttail(e(df_r), abs(_b[transfer2_type_2]/_se[transfer2_type_2]))), .001)
	matrix results[1+`oo',5]=e(N)	
	local oo = `oo'+1
		}
	matrix list results
	svmat results
	keep results*
	drop if _n>$rows
	rename results1 Electronic
	rename results2 Cash
	rename results3 pvalue
	rename results4 munFE_pvalue
	rename results5 N
	gen 	variable = ""
	local oo = 1
	foreach o in $controls{	
	replace variable = "`l`o''" in `oo'
	local oo = `oo'+1
	}
	order 	variable Electronic Cash pval munFE_pvalue N
	format 	Electronic Cash pval munFE_pvalue %5.3f
	export 	excel using "OnlineAppendix/TA9", sheet("TA9") sheetreplace firstrow(variables)
	
